// 用户登录
import request from '@/utils/request.js'
export const login = (data) => {
  return request({
    method: 'POST',
    url: '/v1_0/authorizations',
    data
  })
}
// 发送验证码
export const sendSms = (data) => {
  return request({
    method: 'GET',
    url: '/v1_0/sms/codes/' + data
  })
}
// 获得用户自己信息
export const getUserInfo = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user'
  })
}
// 取消关注
export const deleteFollowed = (target) => {
  return request({
    method: 'DELETE',
    url: '/v1_0/user/followings/' + target
  })
}
// 关注用户
export const getFollowed = (target) => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target
    }
  })
}
// 得到用户个人信息
export const getUserProfile = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user/profile'
  })
}
// 修改用户信息
export const setUserProfile = (data) => {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/profile',
    data
  })
}
// 修改用户头像
export const setUserPhoto = (data) => {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/photo',
    data
  })
}
// 获得用户粉丝列表
export const getUserFans = (data) => {
  return request({
    method: 'GET',
    url: '/v1_0/user/followers',
    params: {
      page: data.page,
      target: data.id
    }
  })
}
// 获得用户关注列表
export const getUserUp = (data) => {
  return request({
    method: 'GET',
    url: '/v1_0/user/followings',
    params: {
      page: data.page,
      target: data.id
    }
  })
}
// 关注用户列表
export const followedUser = (id) => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target: id
    }
  })
}
// 取消关注用户列表
export const deleteUser = (id) => {
  return request({
    method: 'DELETE',
    url: '/v1_0/user/followings/' + id
  })
}
